package geeksforgeeks.trees;

public class SizeOfTree {

	public static void main(String[] args) {
		Node root = new Node(1);

		root.left = new Node(2);
		root.left.right = new Node(5);
		root.left.left = new Node(4);
		root.right = new Node(3);

		int size = printSizeTree(root);
		System.out.println(size);

	}

	private static int printSizeTree(Node root) {
		if(root == null)
			return 0;
		
		return printSizeTree(root.left) + 1 + printSizeTree(root.right);
		
	}

	static class Node {
		int data;
		Node left;
		Node right;

		public Node(int data) {
			this.data = data;
			this.left = this.right = null;
		}
	}

}
